<!DOCTYPE html>
<html>
  <head>
    <% include ../template/admin_meta %>
    <title>淘一个——订单管理</title>
  </head>
  <body>
    <%var nav_index=1;%>
    <% include ../template/admin_header %>
    <div class="main-content-wrapper">
      <div class="container">
        <%
          var parseTime = function(t,num){
            var num = num||2
              ,t = t.toString()
              ;
            for(;num>t.length;num--){
              t='0'+t;
            }
            return t;
          }
          var getLocalFormat = function(date){
              var y=date.getFullYear()
                  ,m=date.getMonth()+1
                  ,d=date.getDate()
                  ,h=date.getHours()
                  ,mi=date.getMinutes()
                  ,s=date.getSeconds()
                ;
              return y+'-'+parseTime(m)+'-'+parseTime(d)+' '+parseTime(h)+':'+parseTime(mi)+':'+parseTime(s)
          }          
        %>
        <% var orders_nav='refundSuccess'; %>
        <% include ../template/orders_nav %>
        <!-- Tab panes -->
        <div class="tab-content">
          <div class="tab-pane active">        
          <table cellpadding="0" cellspacing="0" class="table table-order">
          <thead>
            <tr>
              <th>商品信息</th>
              <th>收货人</th>
              <th>订单金额</th>
              <th>数量</th>
              <th>订单状态</th>
              <th>操作</th>
            </tr>
          </thead>
          <%for(var i=0,len=orderlist.length;i<len;i++){var order=orderlist[i];var D = new Date(order.timestamp);%>
            <tbody>
              <tr class="order-hd">
                <td colspan="6">
                  <span>
                    <%=i+1%>
                  </span>
                  订单编号：
                  <span class="text-primary"><%=order.id%></span>
                  <span class="dealtime"><%=getLocalFormat(D)%></span>
                  <label class="fr">
                    用户：<a href="#"><%=order.user.userName%></a>
                  </label>                   
                </td>
              </tr>
              <tr class="order-bd">
                <td class="goods">
                  <%var product = order.product||{};%>
                  <div class="thumb-list">
                  <a href="#" class="thumb-box"  target="_blank" title="<%=product.title%>">
                  <img src="<%=order.product.thumbImageUrl[0]%>">
                  </a>
                  <span><%=product.title%></span>
                  </div>
                </td>
                <td>
                  收货人：<span class="text-info"><%=(order.addressInfo&&order.addressInfo.name)%></span>
                </td>
                <td class="price">
                  <span>￥<%=order.amount%></span>
                </td>
                <td>
                  <span><%=order.count%></span>  
                </td>
                <td class="status">
                  <span class="text-info"><%=orderStatus[order.status]%></span>  
                </td>
                <td class="operate">
                <%if(order.status==orderStatus.refund){%>
                  <a class="btn btn-danger" target="_blank" href="/admin/orders/setRefundSuccess?id=<%=order.id%>" onclick="if(confirm('确定设置为退款成功？')==false)return false;">
                  完成退款
                  </a> 
                <%}%>   
                </td>
              </tr>
            </tbody>
          <%}%>
          </table>
          </div>
        </div>
        <% include ../template/pagination %>
      </div>      
    </div>

  </body>
</html>